Skip to content

Conversation

@anim001k
Copy link
Contributor

Description

  • Replace local helper function check_value_match with inlined comparison in SparseTrie::find_leaf.

  • Avoids a redundant wrapper and defers cloning Vec<u8> until error construction.

  • Rationale:

    • Reduces cognitive load and eliminates local duplication without changing behavior.
    • Keeps clones only on error path; hot path unaffected.

@mediocregopher
Copy link
Collaborator

defers cloning Vec until error construction.

This was already the case as far as I can tell

expected_value: Option<&Vec<u8>>,
) -> Result<LeafLookup, LeafLookupError> {
// Helper function to check if a value matches the expected value
fn check_value_match(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just add an #[inline] attribute here? It doesn't clone the value unless the error is returned anyway, as @mediocregopher said.

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Oct 21, 2025
@anim001k anim001k requested a review from shekhirin October 21, 2025 07:46
@anim001k
Copy link
Contributor Author

@shekhirin any updates yet?

@anim001k anim001k requested a review from shekhirin October 24, 2025 14:29
@shekhirin shekhirin added C-perf A change motivated by improving speed, memory usage or disk footprint A-trie Related to Merkle Patricia Trie implementation labels Oct 31, 2025
@shekhirin shekhirin enabled auto-merge October 31, 2025 15:46
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 31, 2025

CodSpeed Performance Report

Merging #19138 will improve performances by 10.52%

Comparing anim001k:patch-11 (fd4f7d1) with main (3bb90e6)

Summary

⚡ 1 improvement
✅ 76 untouched

Benchmarks breakdown

Benchmark BASE HEAD Change
hash builder[init size 10000 | update size 100 | num updates 10] 89.1 ms 80.6 ms +10.52%

@shekhirin shekhirin added this pull request to the merge queue Oct 31, 2025
Merged via the queue into paradigmxyz:main with commit dff382b Oct 31, 2025
41 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-trie Related to Merkle Patricia Trie implementation C-perf A change motivated by improving speed, memory usage or disk footprint

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants